package com.linkoog.devtools.view_remark.persistent;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;

@State(name = "ViewRemarkData", storages = @Storage("ApiTest-ViewRemarkData.xml"))
public class ViewRemarkDataPersistent implements PersistentStateComponent<ViewRemarkDataPersistent> {

    public static ViewRemarkDataPersistent getInstance(@NotNull Project project) {
        return project.getService(ViewRemarkDataPersistent.class);
    }

    @Nullable
    @Override
    public ViewRemarkDataPersistent getState() {
        return this;
    }

    @Override
    public void loadState(@NotNull ViewRemarkDataPersistent state) {
        this.aliasMap = state.aliasMap;
        this.prefixMap = state.prefixMap;
        this.subfixMap = state.subfixMap;
    }

    @MapAnnotation
    public Map<String,String> aliasMap = new HashMap<>();
    @MapAnnotation
    public Map<String,String> prefixMap = new HashMap<>();
    @MapAnnotation
    public Map<String,String> subfixMap = new HashMap<>();


    public String getAlias(String key){
        return aliasMap.get(key);
    }

    public void putAlias(String key, String value){
        aliasMap.put(key, value);
    }

    public String getPrefix(String key){
        return prefixMap.get(key);
    }

    public void putPrefix(String key, String value){
        prefixMap.put(key, value);
    }

    public String getSubfix(String key){
        return subfixMap.get(key);
    }

    public void putSubfix(String key, String value){
        subfixMap.put(key, value);
    }

    /*public Map<String, String> getAliasMap() {
        return aliasMap;
    }

    public Map<String, String> getPrefixMap() {
        return prefixMap;
    }

    public Map<String, String> getSubfixMap() {
        return subfixMap;
    }

    public void setAliasMap(Map<String, String> aliasMap) {
        this.aliasMap = aliasMap;
    }

    public void setPrefixMap(Map<String, String> prefixMap) {
        this.prefixMap = prefixMap;
    }

    public void setSubfixMap(Map<String, String> subfixMap) {
        this.subfixMap = subfixMap;
    }*/
}
